bitkeeper revision 1.1236.1.64 (422c8a46Ahc4JfjN3Avhf5LSRWyn8g)
authorakw27@arcadians.cl.cam.ac.uk <akw27@arcadians.cl.cam.ac.uk>
Mon, 7 Mar 2005 17:07:18 +0000 (17:07 +0000)
committerakw27@arcadians.cl.cam.ac.uk <akw27@arcadians.cl.cam.ac.uk>
Mon, 7 Mar 2005 17:07:18 +0000 (17:07 +0000)
fix write-in-place problem -- radix tree wasn't returning writable bit on
lookups.

signed-off-by: andrew.warfield@cl.cam.ac.uk

tools/blktap/parallax.c
tools/blktap/radix.c
tools/blktap/vdi.c
tools/blktap/vdi_snap_list.c

index 24188e692b55e4468799057e7fb9b56a61f5f6bb..15db3ece32a8f39c2671dca6091eccc8c3b377be 100644 (file)
@@ -390,9 +390,7 @@ int parallax_write(blkif_request_t *req, blkif_t *blkif)
                  blkif_first_sect(req->frame_and_sects[i]) + 1
                ) << SECTOR_SHIFT;
         start = blkif_first_sect(req->frame_and_sects[i]) << SECTOR_SHIFT;
-/*       
-if (( gblock != 0 ) && ( writable == 0 )) printf("*");
-*/
+
         DPRINTF("ParallaxWrite: sect: %lld (%ld,%ld),  "
                 "vblock %llx, gblock %llx, "
                 "size %lx\n", 
@@ -407,19 +405,19 @@ if (( gblock != 0 ) && ( writable == 0 )) printf("*");
             printf("]\n] STRANGE WRITE!\n]\n");
             goto err;
         }
-/* Disable write-in-place till radix is sorted out.
+
         if (( gblock == 0 ) || ( writable == 0 )) {
-*/          
+         
             gblock = allocblock(spage);
             vdi_update_block(vdi, vblock, gblock);
-#if 0            
+            
         } else {
             
             /* write-in-place, no need to change mappings. */
             writeblock(gblock, spage);
             
         }
-#endif
+
     }
 
     rsp = (blkif_response_t *)req;
index 1174871010409e94774e7c6a249bb0cbd47e9e07..9c3a7733534eca54b964024b1343054af11207a4 100644 (file)
@@ -76,6 +76,7 @@ radix_tree_node cloneblock(radix_tree_node block) {
  */
 u64 lookup(int height, u64 root, u64 key) {
     radix_tree_node node;
+    u64 mask = ONE;
     
     assert(key >> height == 0);
 
@@ -101,10 +102,11 @@ u64 lookup(int height, u64 root, u64 key) {
             return ZERO;
 
         root = node[(key >> height) & RADIX_TREE_MAP_MASK];
+        mask &= root;
         freeblock(node);
 
         if (height == 0)
-            return root;
+            return ( root & ONEMASK ) | mask;
 
         height -= RADIX_TREE_MAP_SHIFT;
     }
index ea9ebd70da34fad14b321ad28f68a1a79760c70b..e17eb70dacccce22cdd415e93b0b6e18e663eedb 100644 (file)
@@ -136,8 +136,6 @@ u64 vdi_lookup_block(vdi_t *vdi, u64 vdi_block, int *writable)
     gblock = lookup(VDI_HEIGHT, vdi->radix_root, vdi_block);
     
     if (writable != NULL) *writable = iswritable(gblock);
-printf("lu: root: %11Ld, gblock: %11Ld, id: %11Ld, wr: %Ld\n",
-        vdi->radix_root, gblock, getid(gblock), iswritable(gblock));
 
     return getid(gblock);
 }
index 0e37e9497af2cfb17877a5901fb0192113ba7d0b..32b20a6261ecdc0eefc7b84660a53b441fa65dff 100644 (file)
@@ -49,8 +49,8 @@ int main(int argc, char *argv[])
     sid = vdi->snap;
     sid.index--;
     
-    //printf("%6s%4s%21s %12s\n", "Block", "idx", "timestamp", "radix root");
-    printf("%6s%4s%37s %12s\n", "Block", "idx", "timestamp", "radix root");
+    //printf("%8s%4s%21s %12s\n", "Block", "idx", "timestamp", "radix root");
+    printf("%8s%4s%37s %12s\n", "Block", "idx", "timestamp", "radix root");
      
     while (sid.block != 0) {
         blk = snap_get_block(sid.block);
@@ -61,8 +61,8 @@ int main(int argc, char *argv[])
             }
             t = ctime(&blk->snaps[i].timestamp.tv_sec);
             t[strlen(t)-1] = '\0';
-            //printf("%6Ld%4u%14lu.%06lu %12Ld\n",
-            printf("%6Ld%4u%30s %06lu %12Ld\n",
+            //printf("%8Ld%4u%14lu.%06lu %12Ld\n",
+            printf("%8Ld%4u%30s %06lu %12Ld\n",
                     sid.block, i, 
                     //blk->snaps[i].timestamp.tv_sec,
                     t,